class_name CardDatabase
extends RefCounted

# 卡牌数据库
static var cards: Dictionary = {}

static func initialize():
	# 旭的卡牌
	_create_xu_cards()
	# 玲的卡牌
	_create_ling_cards()
	# 澈的卡牌
	_create_chen_cards()

static func _create_xu_cards():
	# 旭 - 力量型角色，高伤害攻击卡
	cards["xu_strike"] = AttackCard.new("xu_strike", "重拳", "基础攻击", 1, 8, 0, GameData.CharacterType.XU)
	cards["xu_heavy_strike"] = AttackCard.new("xu_heavy_strike", "重击", "强力攻击", 2, 15, 1, GameData.CharacterType.XU)
	cards["xu_berserker"] = AttackCard.new("xu_berserker", "狂暴", "失去生命值造成更多伤害", 1, 12, 2, GameData.CharacterType.XU)
	cards["xu_defend"] = SkillCard.new("xu_defend", "防御", "获得护甲", 1, "block", 8, 0, GameData.CharacterType.XU)
	cards["xu_rage"] = SkillCard.new("xu_rage", "愤怒", "获得能量", 0, "energy", 2, 1, GameData.CharacterType.XU)

static func _create_ling_cards():
	# 玲 - 速度型角色，快速攻击
	cards["ling_quick_strike"] = AttackCard.new("ling_quick_strike", "快速打击", "快速攻击", 0, 5, 0, GameData.CharacterType.LING)
	cards["ling_flurry"] = AttackCard.new("ling_flurry", "连击", "连续攻击", 1, 6, 1, GameData.CharacterType.LING)
	cards["ling_precision"] = AttackCard.new("ling_precision", "精准", "高命中攻击", 1, 9, 1, GameData.CharacterType.LING)
	cards["ling_dodge"] = SkillCard.new("ling_dodge", "闪避", "获得护甲", 1, "block", 4, 0, GameData.CharacterType.LING)
	cards["ling_agility"] = SkillCard.new("ling_agility", "敏捷", "抽牌", 1, "draw", 3, 1, GameData.CharacterType.LING)

static func _create_chen_cards():
	# 澈 - 成长型角色，混合能力
	cards["chen_study"] = AttackCard.new("chen_study", "学习", "基础攻击", 1, 6, 0, GameData.CharacterType.CHEN)
	cards["chen_exam_practice"] = AttackCard.new("chen_exam_practice", "考试练习", "练习攻击", 2, 10, 1, GameData.CharacterType.CHEN)
	cards["chen_rest"] = SkillCard.new("chen_rest", "休息", "恢复生命", 1, "heal", 6, 0, GameData.CharacterType.CHEN)
	cards["chen_growth"] = SkillCard.new("chen_growth", "成长", "获得能量", 0, "energy", 1, 1, GameData.CharacterType.CHEN)
	cards["chen_wisdom"] = SkillCard.new("chen_wisdom", "智慧", "抽牌并恢复生命", 2, "draw", 2, 2, GameData.CharacterType.CHEN)

static func get_card(card_id: String) -> Card:
	if cards.has(card_id):
		return cards[card_id].duplicate_card()
	return null

static func get_character_cards(character: GameData.CharacterType) -> Array[Card]:
	var character_cards: Array[Card] = []
	for card in cards.values():
		if card.character == character:
			character_cards.append(card.duplicate_card())
	return character_cards
